puts "===================================================="
puts "Adding engine to make pretty url(s)"
puts "===================================================="
  module ActiveRecord #:nodoc:
    class Base
      after_create :make_or_update_pretty_url_name
      
      #protected
      def make_or_update_pretty_url_name
        parent_column = nil
        stripped_column = self.attributes.collect {|x| x.to_s.include?("stripped_") ? x : nil}.flatten.compact.first
        if stripped_column
           parent_column = stripped_column.gsub("stripped_","")
          if self.send(parent_column)
            self.send("#{stripped_column}=",stripp_it(self.send(parent_column)))
            if self.class.find(:all, :conditions => ["#{stripped_column} =  ?",self.send(stripped_column)]).length > 0
              self.send("#{stripped_column}=","#{self.send(stripped_column)}-#{self.id.to_s}")
            end
            self.send("save")
           end
        end
      end

      def stripp_it(str)
        str.strip.downcase.gsub(/[^a-z0-9]/,"-").gsub(/(-)+/,"-").gsub(/(-)+$/,"")
      end
    end
  end